﻿package  Welsy4.Connect.business
{
    import mx.rpc.IResponder;
	import mx.rpc.http.HTTPService;	
	import com.adobe.cairngorm.business.ServiceLocator;	
	import mx.rpc.AsyncToken;
	import flash.net.URLVariables;
	import Welsy4.Connect.vo.User;
	import Welsy4.Connect.model.ConnectModel;
	
	public class CommonInfoDelegate 
	{
		
		private var responder : IResponder;
        private var service : Object;
                
        public function CommonInfoDelegate( responder : IResponder )
        {
            this.service = ServiceLocator.getInstance().getHTTPService("FakeAPI" );
            this.responder = responder;
        }
		
		public function getCommonInfo():void {
		    var token:AsyncToken = HTTPService(service).send(new URLVariables("action=common-info&no-cache="+User.getLoginRequestlocaleTime() ));
			token.addResponder(responder);
		}
		
		public function getSCOShortcuts():void {
			var request:URLVariables = new URLVariables("action=sco-shortcuts&nocache="+ User.getLoginRequestlocaleTime() + "&session="+ConnectModel.getInstance().sessionCookie);
			var token : AsyncToken = HTTPService(service).send(request);
			token.addResponder(responder);
		}
		
		public function getSCOContents(sco_id:String, filter_type:String, filter_name:String):void {
			var request:URLVariables = new URLVariables("action=sco-contents");
			request.decode("sco-id=" + sco_id);
			request.decode("filter-type=" + filter_type);
			request.decode("filter-name=" + filter_name);
			
			request.nocache = User.getLoginRequestlocaleTime();
			request.session = ConnectModel.getInstance().sessionCookie;
			
			var token : AsyncToken = HTTPService(service).send(request);
			token.addResponder(responder);
		}
		
		
	}
	
}